
/****** Object:  StoredProcedure [dbo].[ws_ins_mokejimas]    Script Date: 10/19/2013 09:20:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'ws_ins_mokejimas')
DROP PROCEDURE ws_ins_mokejimas
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[ws_ins_mokejimas]
	@pid varchar(12),
	@op_data varchar(20),
	@id varchar(35),
	@suma varchar(20),
	@paved_nr varchar(35),
	@val char(3),
	@imok_kodas varchar(35),
	@g_bankas varchar(100), 
	@g_saskaita varchar(25),
	@m_kodas_ks varchar(12),
	@m_pav varchar(40),
	@m_bankas varchar(100),
	@m_saskaita varchar(25),
	@paskirtis1 varchar(140),
	@paskirtis2 varchar(140),
	@paskirtis3 varchar(140),
	@user_id varchar(16)
AS
BEGIN
	SET NOCOUNT ON
	
	declare @data datetime
	declare @aparato_pav varchar(50)
	declare @aparato_id int
	
	SET @data = convert(datetime,@op_data ,126)
	SELECT @aparato_id = Aparatoid FROM ws_users WHERE user_id = @user_id
	SELECT @aparato_pav = AparatoPavadinimas FROM aparatai WHERE AparatoID = @aparato_id
	
	
	insert into I04_ATH_C (I04_C_KODAS_CH,I04_C_OP_DATA,I04_C_ID,I04_C_SUMA,
	I04_C_Paved_nr,I04_C_VAL,I04_C_IMOK_KODAS,I04_C_G_KODAS_KS,I04_C_G_PAV,I04_C_G_BANKAS,I04_C_G_SASKAITA,
	I04_C_M_KODAS_KS,I04_C_M_PAV,I04_C_M_BANKAS,I04_C_M_SASKAITA,I04_C_PASKIRTIS1,I04_C_PASKIRTIS2,I04_C_PASKIRTIS3,I04_C_APARATOID,I04_C_AparatoPavadinimas) 
	VALUES (@pid,@data,@id,CAST(@suma as decimal(12,2)),
	@paved_nr,@val,@imok_kodas,'','',@g_bankas,@g_saskaita,
	@m_kodas_ks,@m_pav,@m_bankas,@m_saskaita,@paskirtis1,@paskirtis2,@paskirtis2,@aparato_id,@aparato_pav)

END

GO



